package com.ht.action;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

import com.ht.dao.impl.StaffDAOImpl;
import com.ht.service.impl.JBPMServiceImpl;
import com.ht.util.BaseAction;
import com.opensymphony.xwork2.ActionContext;
/**
 * 
 * @author ht 
 * 	2010 10 20
 *
 */
public class TaskListAction extends BaseAction{
	

	private String assignee;
	 
	private List taskList;
	 
	public String getTasks(){
		JBPMServiceImpl jbpmServiceImpl = new JBPMServiceImpl();
		System.out.println("assignee="+assignee);
		String staffName = (String)ActionContext.getContext().getSession().get("staffName");
		System.out.println("staffName="+staffName);
		if(assignee.equals("staff")){	//用户身份
			taskList=jbpmServiceImpl.getTasksList(staffName);
			if(taskList.size()==0){		//如果没有任务,跳转到请求页面
				return "request";
			}else{					//如果有被驳回的任务，跳转到原请求列表页面
				return "requestList";
			}
		}else {
//			String sql="select * from `staff` where staffName='"+staffName+"'";
//			StaffDAOImpl daoImpl = new StaffDAOImpl();
//			List list = daoImpl.findStaff(sql);
//			Map map = (HashMap)list.get(0);
//			if(map.get("staffPosition").equals("manager") || map.get("staffPosition").equals("boss") )
			taskList=jbpmServiceImpl.getTasksList(assignee);
		}
		
		return "tasks"; //查看请假列表
	}

	public String getAssignee() {
		return assignee;
	}

	public void setAssignee(String assignee) {
		this.assignee = assignee;
	}

	public List getTaskList() {
		return taskList;
	}

	public void setTaskList(List taskList) {
		this.taskList = taskList;
	}


	


	
}
